package cn.tedu.net.collection.basic;
//ArrayList集合的使用
import java.util.ArrayList;
public class Arraylist {
    public static void main(String[] ages){
        ArrayList<Integer> list = new ArrayList<>();
        //生成10个随机数放入list集合
        for (int i = 0; i < 10 ;i++) {
            list.add((int)(Math.random()*100));
        }
        int d = 0;
        // 冒泡排序
        for (int i = 0; i < list.size()-1; i++) {
            System.out.println("第"+(i+1)+"轮排序结果为:"+list.toString());
            for (int j = 0; j < list.size()-1; j++) {
                if(list.get(j)>list.get(j+1)) {
                    int a = list.get(j);
                    int b = list.get(j+1);
                    list.set(j,b);
                    list.set(j+1,a);
                    d=1;

                }

            }
            if(d==0) break;
        }
        System.out.println(list);
    }
}
